export default (Vue) => {
    Vue.mixin({

        methods: {
            debounceFun(func, wait) {
                let timeout;
                return function () {
                    let context = this;
                    let args = arguments;

                    if (timeout) clearTimeout(timeout);

                    timeout = setTimeout(() => {
                        func.apply(context, args)
                    }, wait);
                }
            },
            // 表单验证
            checkFormSync(formName) {
                return new Promise((resolve, reject) => {
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                            resolve(valid);
                        } else {
                            reject(valid);
                        }
                    });
                })
            },

        }
    })
}